//
//  RecordNewView.m
//  NewGame
//
//  Created by wwj on 15/10/27.
//  Copyright © 2015年 wwj. All rights reserved.
//

#import "RecordNewView.h"
#import "SoundTool.h"

@interface RecordNewView ()
@property (weak, nonatomic) IBOutlet UIImageView *lightView;
@property (weak, nonatomic) IBOutlet UIView *highScoreView;
@property (weak, nonatomic) IBOutlet UIView *recordNewBoard;
@end

@implementation RecordNewView

+(instancetype)recordNewView{
    return [[[NSBundle mainBundle] loadNibNamed:@"RecordNewView" owner:nil options:nil] firstObject];
}

-(void)awakeFromNib{
    _lightView.animationImages = @[
      [UIImage imageNamed:@"scene_light01"],
      [UIImage imageNamed:@"scene_light02"],
      [UIImage imageNamed:@"scene_light03"]
    ];
    _lightView.animationDuration = 0.3;
    _recordNewBoard.transform = CGAffineTransformMakeRotation(M_PI_4 / 10);
}

-(void)begin{
    [_lightView startAnimating];
    CABasicAnimation *anim = [CABasicAnimation animationWithKeyPath:@"transform.translation.x"];
    anim.fromValue = @0;
    anim.toValue = @375;
    anim.repeatCount = MAXFLOAT;
    anim.duration = 1;
    [_highScoreView.layer addAnimation:anim forKey:nil];
    
    // 3.播放声音
    [[SoundTool sharedSoundTool] playSound:kSoundRecordNew2];
    
    CGAffineTransform transform = _recordNewBoard.transform;
    transform = CGAffineTransformScale(transform, 1.24, 1.24);
    [UIView animateWithDuration:0.3 animations:^{
        _recordNewBoard.transform = transform;
        [[SoundTool sharedSoundTool] playSound:kSoundRecordNew1];
    }];
    
}
@end
